﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DTO;
using DataService;
public partial class _Default : BasePage
{
    private Customer _customer;
    private DeviceService _service;
    public _Default()
    {
        _service = new DeviceService();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (UserLogin == null)
        {
            Response.Redirect("Login.aspx");
        }
        Initial();        
    }

    private void Initial ()
    {
        if (UserLogin != null)
        {
            _customer = UserLogin.Customer;
            DisplayInfo();
        }
    }

    private void DisplayInfo ()
    {
        litCompanyOverview.Text += _customer.CompanyName + "<br />";
        litCompanyOverview.Text += _customer.MainContact.ToString() + "<br />";
        litCompanyOverview.Text += "Setup on " + _customer.Created.ToString("D") + "<br />";

        lblNextCharge.Text = _customer.NextPaymentOn.ToString("MMMM yyyy");
        lblCurrentRate.Text = "$5.073,68";//_customer.BillingAmount;
        lblCurrentReferrals.Text = "$10.147,36";//_customer.Referrals.ToString("C");

        litAboutYou.Text = UserLogin.ToString();

        List<Person> people = new List<Person>();
        people.AddRange(_customer.Contacts);
        people.AddRange(_customer.Users);

        lstPepole.DataSource = people;
        lstPepole.DataBind();

        lblVolumeAllocation.Text = _customer.Bandwidth.VolumeAllocation.ToString("N") + " Gb";
        lblVolumeUsed.Text = _customer.Bandwidth.VolumeUsed.ToString("N") + " Gb";
        lblEstimatedVolume.Text = _customer.Bandwidth.EstimatedVolume.ToString("N") + " Gb";
        lblThroughputQuota.Text = _customer.Bandwidth.ThroughputQuota.ToString("N") + " Mbps";
        lblThroughput95thPercentile.Text = _customer.Bandwidth.Throughput95thPercentile.ToString("N") + " Mbps";

        IList<Device> devices= _service.GetListDeviceByAccountId(UserLogin.Customer.Id);
        lstDevices.DataSource = devices;
        lstDevices.DataBind();
    }
}
